/**
 * Created by apple on 2017/12/28.
 */
var DBFactory = require('../db/mysql_db');
var async = require('async');
var FreezeMoneyDao = module.exports;
var Global = require('../global_var');
var Config = require('../config');


FreezeMoneyDao.getFreezeList = function (data,cb) {

    if (!data) return cb(new Error(500));

    var sql = 'SELECT * FROM freeze_money_record WHERE uid = ? ';
    var value = [data.uid];
    if (data.app_sid) {
        sql += ' AND app_sid = ? ';
        value.push(data.app_sid);
    }
    sql += ' ORDER BY created_time DESC ';
    var pageSize = data.pageSize ? data.pageSize : 10;
    var page = data.page ? data.page : 1;
    sql += 'LIMIT ' + (page - 1) * pageSize + ',' + pageSize;

    DBFactory.poolQuery(sql, value,
        function () {
            cb('no collection');
        },
        function (err, result) {
            if (err) {
                console.log(err);
                cb(err);
                return;
            }
            cb(null, {freezeList:result});
        }
    );

}

